<h2>ต้นทุน : <?php echo $phaseName[$_GET["phaseID"]];?></h2>
<table style="width: 100%;">
    <?php
        $query="
            select      *
            from        phase
            order by    phaseID desc
            ";
        $result=  $mysqli->query($query);
        $row=  $result->fetch_array(MYSQLI_ASSOC);
        $maxPhaseID=$row["phaseID"];
        $query="
            select  *
            from    cost_phase
            ";
        $result=  mysql_query($query) or die(mysql_error());
        $numrows=  $result->num_rows;
        $i=0;
        $costCount=0;
        while($i<$numrows){
            $row=  $result->fetch_array(MYSQLI_ASSOC);
            if($row["mat"]=="true"){
                $costCount++;
            }
            
            if($row["wage"]=="true"){
                $costCount++;
            }
            ?>
    <tr>
        <td colspan="2"><?=$row["cpName"]?></td>
    </tr>
    <tr>
        
        <?php
            if($row["mat"]=="true"){
                ?>
        <td style="padding-bottom: 10px">
            <div class="input-group">
                <span class="input-group-addon" style="width: 70px;">ค่าวัสดุ</span>
                <input type="tel" name="mat[]" class="form-control">
                <span class="input-group-addon">บาท</span>
            </div>
        </td>
                    <?php
            }
            
            if($row["wage"]=="true"){
                ?>
        <td style="padding-bottom: 10px">
            <div class="input-group">
                <span class="input-group-addon" style="width: 70px;">ค่าแรง</span>
                <input type="tel" name="wage[]" class="form-control">
                <span class="input-group-addon">บาท</span>
            </div>
        </td>
                    <?php
            }
        ?>
        
    </tr>
                <?php
            $costCount=0;
            $i++;
        }
    ?>
</table>
<?php
    if($phaseID+1>$maxPhaseID){
        ?>
<input type="submit" value="ผลตอบแทน" class="btn btn-default" style="float: right;"
       onclick="window.open('.?page=costAFPhase','_self')"
       >
            <?php
    }else{
        ?>
<input type="submit" value="ต่อไป > " class="btn btn-default" style="float: right;"
       onclick="window.open('.?page=costPhase&phaseID=<?=$phaseID+1?>','_self')"
       >
            <?php
    }
?>